﻿<UserControl x:Class="tomenglertde.ResXManager.View.Visuals.TranslatorConfiguration"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" mc:Ignorable="d" d:DesignWidth="800"
             xmlns:wpf="urn:TomsToolbox"
             xmlns:properties="clr-namespace:tomenglertde.ResXManager.View.Properties"
             xmlns:styles="urn:ResXManager.Styles"
             xmlns:infrastructure="urn:ResXManager.Infrastructure">
  <TabControl TabStripPlacement="Left" Loaded="TabControl_Loaded" Style="{DynamicResource {x:Static styles:ResourceKeys.TabControlStyle}}"
              ItemsSource="{Binding Translators, RelativeSource={RelativeSource FindAncestor, AncestorType=UserControl}}" >
    <TabControl.ItemTemplate>
      <DataTemplate>
        <TextBlock Text="{Binding DisplayName}" Margin="4"/>
      </DataTemplate>
    </TabControl.ItemTemplate>
    <TabControl.ContentTemplate>
      <DataTemplate DataType="infrastructure:ITranslator">
        <StackPanel Margin="5">
          <DockPanel Margin="10,0">
            <CheckBox DockPanel.Dock="Left" Content="{x:Static properties:Resources.Enabled}" IsChecked="{Binding IsEnabled}" VerticalAlignment="Bottom"  Style="{DynamicResource {x:Static styles:ResourceKeys.CheckBoxStyle}}" />
            <Decorator DockPanel.Dock="Left" Width="20"/>
            <Button Tag="{Binding Uri, Mode=OneWay}" HorizontalAlignment="Right">
              <Button.Template>
                <ControlTemplate>
                  <TextBlock TextTrimming="CharacterEllipsis"><Hyperlink Focusable="False" NavigateUri="{Binding Uri, Mode=OneWay}" ><Run Text="{Binding Uri, Mode=OneWay}" /></Hyperlink></TextBlock>
                </ControlTemplate>
              </Button.Template>
            </Button>
          </DockPanel>
          <Decorator Height="5"/>
          <GroupBox x:Name="AuthenticationGroup" Header="{x:Static properties:Resources.Authentication}"
                    Grid.IsSharedSizeScope="True" Style="{DynamicResource {x:Static styles:ResourceKeys.GroupBoxStyle}}">
            <StackPanel>
              <ItemsControl ItemsSource="{Binding Credentials}" Margin="2" Focusable="False">
                <ItemsControl.ItemTemplate>
                  <DataTemplate DataType="infrastructure:ICredentialItem">
                    <wpf:SharedWidthHeaderedContentControl Margin="2">
                      <wpf:SharedWidthHeaderedContentControl.Header>
                        <TextBlock DockPanel.Dock="Left"><Run Text="{Binding Description, Mode=OneWay}"/><Run Text=": "/></TextBlock>
                      </wpf:SharedWidthHeaderedContentControl.Header>
                      <TextBox Text="{Binding Value, UpdateSourceTrigger=PropertyChanged}" Style="{DynamicResource {x:Static styles:ResourceKeys.TextBoxStyle}}"/>
                    </wpf:SharedWidthHeaderedContentControl>
                  </DataTemplate>
                </ItemsControl.ItemTemplate>
              </ItemsControl>
              <wpf:SharedWidthHeaderedContentControl Margin="2,0">
                <CheckBox Margin="1" Content="{x:Static properties:Resources.TranslatorConfiguration_SaveCredentials}" IsChecked="{Binding SaveCredentials}" Style="{DynamicResource {x:Static styles:ResourceKeys.CheckBoxStyle}}"/>
              </wpf:SharedWidthHeaderedContentControl>
            </StackPanel>
          </GroupBox>
        </StackPanel>
        <DataTemplate.Triggers>
          <DataTrigger Binding="{Binding Credentials.Count, FallbackValue=0}" Value="0">
            <Setter TargetName="AuthenticationGroup" Property="Visibility" Value="Collapsed"/>
          </DataTrigger>
        </DataTemplate.Triggers>
      </DataTemplate>
    </TabControl.ContentTemplate>
  </TabControl>
</UserControl>
